//
//  UserAccountSecurityCell.m
//  CheekiOS
//
//  Created by mac on 2017/6/22.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UserAccountSecurityCell.h"

@interface UserAccountSecurityCell()


@property (nonatomic, strong)UIImageView *imgView;
@property (nonatomic, strong)UILabel *photoNumLab;
@property (nonatomic, strong)UILabel *bindingLab;
@property (nonatomic, strong)UIImageView *protectImg;
@property (nonatomic, strong)UILabel *protectLab;

@property (nonatomic, strong)UILabel *linLabTwo;

@property (nonatomic, assign)NSIndexPath *indexPath;

@end

@implementation UserAccountSecurityCell

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath*)indexPath {
    
    static NSString *UserAccountSecurityCellIdent = @"UserAccountSecurityCellIdent";
    UserAccountSecurityCell *cell = [tableView dequeueReusableCellWithIdentifier:UserAccountSecurityCellIdent];
    if (!cell) {
        cell = [[UserAccountSecurityCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UserAccountSecurityCellIdent];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.indexPath = indexPath;
    if (indexPath.row == 0) {
        cell.accessoryType = UITableViewCellAccessoryNone;

    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        

        
        self.linLabTwo = [UILabel new];
        self.linLabTwo.backgroundColor = RGB(243, 243, 243);
        [self addSubview:self.linLabTwo];
        
        self.imgView = [[UIImageView alloc] init];
        [self addSubview:self.imgView];
        
        self.photoNumLab = [UILabel new];
        self.photoNumLab.textColor = [UIColor blackColor];
        self.photoNumLab.textAlignment = NSTextAlignmentLeft;
        self.photoNumLab.font = FontP(15);
        [self addSubview:self.photoNumLab];
        
        self.bindingLab = [UILabel new];
        self.bindingLab.textColor = ColorI(0x2e353f);
        self.bindingLab.textAlignment = NSTextAlignmentLeft;
        self.bindingLab.font = FontP(15);

        [self addSubview:self.bindingLab];

        self.protectImg = [[UIImageView alloc]init];
        [self addSubview:self.protectImg];
        
        self.protectLab = [UILabel new];
        self.protectLab.textColor = ColorI(0x55c857);
        self.protectLab.textAlignment = NSTextAlignmentLeft;
        self.protectLab.font = FontP(15);

        [self addSubview:self.protectLab];
    }
    return self;
}

-(void)setModel:(UserpersionlInfoModel *)model{

    [self.linLabTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_bottom).offset(-1);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(1);
    }];
    
   
    
    if (_indexPath.row == 1) {
        
        
        [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(15);
            make.left.equalTo(self).offset(15);
            make.width.height.mas_equalTo(25);
        }];
        
        [self.photoNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(15);
            make.left.equalTo(self.imgView.mas_right).offset(15);
            make.height.mas_equalTo(25);
        }];
        
        [self.bindingLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(15);
            make.right.equalTo(self).offset(-35);
            make.height.mas_equalTo(25);
        }];
        
        if(model.mobile.length!=0 && model.mobile!=nil){
            self.bindingLab.text = model.mobile;
        }else{
            self.bindingLab.text = @"未绑定";
        }
        
        self.imgView.image = [UIImage imageNamed:@"p_center_sz_button_ipone"];
        
    }else if (_indexPath.row == 2){
        [self.photoNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(15);
            make.left.equalTo(self).offset(15);
            make.height.mas_equalTo(25);
        }];
        
    
    }
    //账号与安全  现在不用
//    else if(_indexPath.row == 3) {
//        [self.photoNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self).offset(15);
//            make.left.equalTo(self).offset(15);
//            make.height.mas_equalTo(25);
//        }];
//        
//        [self.protectLab mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self).offset(15);
//            make.right.equalTo(self).offset(-35);
//            make.height.mas_equalTo(25);
//        }];
//        
//        [self.protectImg mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self).offset(20);
//            make.right.equalTo(self.protectLab.mas_left).offset(0);
//            make.height.width.mas_equalTo(15);
//        }];
//        self.protectImg.image = [UIImage imageNamed:@"p_center_szaq_lock_button"];
//        
//
//        if ([model.deviceProtect isEqualToString:@"1"]) {
//            self.protectLab.text = @"已开启";
//        }else{
//            self.protectLab.text = @"未开启";
//            
//        }
//    }

    if (_indexPath.row == 1) {
        self.photoNumLab.text = @"手机号";
    }else if (_indexPath.row == 2){
    self.photoNumLab.text = @"修改密码";
    }
//    else if (_indexPath.row == 3){
//    self.photoNumLab.text = @"设备与安全";
//    }

    

    
}


@end
